<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<section class="content-header">
	<h1>
		<spring:message code='grupos.header' />
		<small>Grupos Cadastrados</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
		<li><a href="#">Tables</a></li>
		<li class="active">Simple</li>
	</ol>
</section>

<section class="content">
	<div class="row" ng-controller="gruposController">
		<div class="col-xs-12">
			<!-- /.modal-dialog -->
				<div class="alert alert-success alert-dismissable"
					ng-show="successOnSubmit">
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<spring:message code="request.error" />
				</div>
				<div class="alert alert-danger alert-dismissable"
					ng-show="errorOnSubmit">
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<spring:message code="request.error" />
				</div>
			<div class="box">				
				<div class="box-header">
					<h3 class="box-title">
						<spring:message code='grupos.header' />
					</h3>
					<div class="box-tools">
						<div class="input-group">
							<input type="text" name="table_search"
								class="form-control input-sm pull-right" style="width: 150px;"
								placeholder="Search" />
							<div class="input-group-btn">
								<button class="btn btn-sm btn-default">
									<i class="fa fa-search"></i>
								</button>
							</div>
						</div>
					</div>
				</div>
				<!-- /.box-header -->
				<div class="box-body"
					ng-class="{'': state == 'list', 'none': state != 'list'}">
					<div id="example2_wrapper" class="dataTables_wrapper form-inline" role="grid">
					<div class="row">
	<div class="col-xs-6"></div>
	<div class="col-xs-6"></div>
	</div>
					<table id="example1" class="table table-bordered table-striped"
						aria-describedby="example2_info">
						<thead>
							<tr>
								<th scope="col"><spring:message code="grupos.id" /></th>
								<th scope="col"><spring:message code="grupos.nome" /></th>
								<th scope="col">Ações</th>
							</tr>
						</thead>
						<tbody>
							<tr ng-repeat="grupo in page.source">
								<td>{{grupo.id}}</td>
								<td>{{grupo.nome}}</td>
								<td >
									<div class="mailbox-controls">
										<input type="hidden" value="{{grupo.id}}"/>
			                            <a href="#updateGruposModal"
			                               ng-click="selectedGrupo(grupo);"
			                               role="button"
			                               title="<spring:message code="update"/>&nbsp;<spring:message code="grupo"/>"
			                               class="btn btn-default btn-sm" data-toggle="modal">
			                                <i class="fa fa fa-pencil"></i>
			                            </a>
										
										<a href="#deleteGruposModal"
			                               ng-click="selectedGrupo(grupo);"
			                               role="button"
			                               title="<spring:message code="delete"/>&nbsp;<spring:message code="grupo"/>"
			                               class="btn btn-default btn-sm" data-toggle="modal">
			                                <i class="fa fa-trash-o"></i>
			                            </a>
									</div>
								</td>
							</tr>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
					<div class="row">
						<div class="col-xs-6">
							<div id="example2_info" class="dataTables_info">
								Mostrando {{page.currentPage
								+ 1}} <spring:message code="pagination.of" />
								{{page.pagesCount}} of {{page.totalGrupos}} entradas</div>
							
						</div>
						<div class="col-xs-6">
							<div class="dataTables_paginate paging_bootstrap">
								<div ng-repeat="num in proxNum(page.pagesCount)">
									{{num}}
								</div>
								<ul class="pagination">
									<li ng-repeat="num in proxNum(page.pagesCount)">{{num}}</li>
									<li>
										<a href="#"							               
							               ng-class="{'btn-inverse': page.currentPage != 0, 'disabled': page.currentPage == 0}"
							               ng-disabled="page.currentPage == 0" ng-click="changePage(0)"
							               title='<spring:message code="pagination.first"/>' >       
							                <spring:message code="pagination.first"/>
							            </a>
									</li>
									<li>
										<a href="#"							               
							                ng-class="{'btn-inverse': page.currentPage != 0, 'disabled': page.currentPage == 0}"
					                        ng-disabled="page.currentPage == 0" class="btn btn-inverse"
					                        ng-click="changePage(page.currentPage - 1)"
					                        title='<spring:message code="pagination.back"/>' > 
					                        &lt;
							             
							            </a>
									</li>
									<li>
										<a href="#"							               
							               ng-class="{'btn-inverse': page.pagesCount - 1 != page.currentPage, 'disabled': page.pagesCount - 1 == page.currentPage}"
					                        ng-click="changePage(page.currentPage + 1)"
					                        ng-disabled="page.pagesCount - 1 == page.currentPage"
					                        title='<spring:message code="pagination.next"/>' >       
							                &gt;
							            </a>
									</li>
									<li>
										<a href="#"							               
							               ng-class="{'btn-inverse': page.pagesCount - 1 != page.currentPage, 'disabled': page.pagesCount - 1 == page.currentPage}"
						                        ng-disabled="page.pagesCount - 1 == page.currentPage"
						                        ng-click="changePage(page.pagesCount - 1)"
						                        title='<spring:message code="pagination.last"/>' >       
							                <spring:message code="pagination.last"/>
							            </a>
									</li>
								</ul>
							</div>
						</div>
					</div>			
				</div>
				</div>
				<!-- /.box-body -->
				
				<div class="box-footer" ng-class="{'text-center': displayCreateGrupoButton == true, 'none': displayCreateGrupoButton == false}">
					<a href="#addGruposModal"
			               role="button"
			               ng-click="resetGrupo();"
			               title="<spring:message code='create'/>&nbsp;<spring:message code='grupo'/>"
			               class="btn btn-primary"
			               data-toggle="modal">       
			                &nbsp;&nbsp;<spring:message code="create"/>&nbsp;<spring:message code="grupo"/>
			            </a>
			            <jsp:include page="dialogs/gruposDialogs.jsp"/>
				</div>
				
			</div>
			<!-- /.box -->
		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->	
</section>
<script src="<c:url value="/resources/js/pages/grupos.js" />"></script>